import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
  // 更改路由链接激活项的类名
  // linkActiveClass: 'router-active',
  history: createWebHashHistory(),

  // 3. 命名路由
  routes: [
    { path: '/',redirect: '/login'},
    { path: '/login', component: () => import('../components/Login.vue')},
    { path: '/modifyPwd', component: () => import('../components/ModifyPwd.vue') },
    { path: '/index', component: () => import('../components/index.vue') },
    // { path: '/robe', component: () => import('../views/robe.vue') },
    // { path: '/bclothing', component: () => import('../views/bclothing.vue') },
    // { path: '/accessory', component: () => import('../views/accessory.vue') },
    // { path: '/fan', component: () => import('../views/fan.vue') },
    // { path: '/cufflink', component: () => import('../views/cufflink.vue') },

    // {
      // path: '/movie',
      // component: () => import ('./components/Movie.vue'),
      // children: [
        // { path: ':id', name: 'MovieDetails', component: () => import ('./components/movieDetails.vue'), props: true }
      // ]
    // },
    // 导航守卫-登录组件
    // { path: '/login', name: 'Login', component: () => import ('./components/Login.vue') }
  ]
})

// 注册全局导航守卫
// router.beforeEach((to, from, next) => {
//   let isLogin = false
//   if (to.name == 'MovieDetails') {
//     if (isLogin) {
//       next()
//     } else {
//       next({ name: 'Login' })
//     }
//   } else {
//     next()
//   }
// })

export default router

